#ifndef GAME_PART_H_
#define GAME_PART_H_
#include <vector>
#include <set>
#include <list>
#include <map>
#include "ui.h"
#include <SDL/SDL_image.h>
#include "sence_config.h"
#include "myrand.h"
#include "../imageproc/image.h"
#include <iostream>
using namespace std;
class Pic{
private:
	int moveTimes;
	double dx,dy,dw;
	int dst_left,dst_bottom,dst_width;
	SDL_Rect src;
	SDL_Rect dst;
	SDL_Surface* Surface;
	SDL_Surface* OriSurface;
public:
	Pic(int dstLeft,int dstBottom,double dx,double dy,double dw,SDL_Surface* surface,SDL_Surface* oriSurface);
	bool Move();
	SDL_Rect SrcRect() const { return this->src; }
	SDL_Rect DstRect() const { return this->dst; }
	SDL_Surface* GetSurface() { return this->Surface; }
	SDL_Surface* GetOriginalSurface() { return this->OriSurface; }
	bool operator > (const Pic& p) const;
	bool operator == (const Pic& p) const;
	bool operator < (const Pic& p) const;
	bool operator != (const Pic& p) const;
	bool operator >= (const Pic& p) const;
	bool operator <= (const Pic& p) const;
private:
	void updateRect(int dstLeft,int dstBottom);
};
	

class Game_Part{
private:
	static list<Game_Part*> part_list;
	static multiset<Pic> pictures;
	static void add(Game_Part*);
	static void remove(Game_Part*);
	static void refreshScreen();
public:
	Game_Part(){ add(this);  }
	virtual ~Game_Part(){ remove(this); }
	virtual bool TimerTick() = 0;
	virtual void UpdateToScreen() = 0;
	static bool TickAllParts();
	static void Destroy(vector<SDL_Surface*>& vec);
	static void Destroy(list<Pic*>& vec);
	static void LoadPicture(vector<SDL_Surface*>& vec,int num,const string& folder);
	static void Add(Pic* p);	
	static int SumPow2(int num);
};
#endif
